﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Shell : MonoBehaviour
{
    public GameObject shellExpPrefab;       //子弹
    public AudioClip shellExpAud;           //子弹音效
    public float timer = 1.5f;              //如果没有碰撞，子弹存活时间
    // Start is called before the first frame update
    void Start()
    {
        GameObject.Destroy(this.gameObject, timer);
    }

    // Update is called once per frame
    void Update()
    {
        
    }

    void OnTriggerEnter(Collider other)
    {
        AudioSource.PlayClipAtPoint(shellExpAud, transform.position);
        GameObject.Instantiate(shellExpPrefab, transform.position, transform.rotation);
        GameObject.Destroy(this.gameObject);
        if(other.tag == "Tank"){
            other.SendMessage("TankDamage");
        }
    }
}
